package com.ruoyi.project.module.zxy;

import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.project.domain.YqgInformationRoom;
import com.ruoyi.project.service.IYqgInformationRoomService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;


/**
 * 房间基础信息Controller
 *
 * @author dr
 * @date 2023-04-17
 */
@RestController
@RequestMapping("/zxy/room")
public class ZxyYqgInformationRoomController extends BaseController
{
    @Autowired
    private IYqgInformationRoomService yqgInformationRoomService;

    /**
     * 查询房间基础信息列表
     */
//    @RequiresPermissions("project:room:list")
    @GetMapping("/list")
    public TableDataInfo list(YqgInformationRoom yqgInformationRoom)
    {
        startPage();
        List<YqgInformationRoom> list = yqgInformationRoomService.selectYqgInformationRoomList(yqgInformationRoom);
        return getDataTable(list);
    }

    /**
     * 导出房间基础信息列表
     */
//    @RequiresPermissions("project:room:export")
    @Log(title = "导出", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, YqgInformationRoom yqgInformationRoom)
    {
        List<YqgInformationRoom> list = yqgInformationRoomService.selectYqgInformationRoomList(yqgInformationRoom);
        ExcelUtil<YqgInformationRoom> util = new ExcelUtil<YqgInformationRoom>(YqgInformationRoom.class);
        util.exportExcel(response, list, "房间基础信息数据");
    }

    /**
     * 获取房间基础信息详细信息
     */
//    @RequiresPermissions("project:room:query")
    @GetMapping(value = "/{ID}")
    public AjaxResult getInfo(@PathVariable("ID") Long ID)
    {
        return success(yqgInformationRoomService.selectYqgInformationRoomByID(ID));
    }

    /**
     * 新增房间基础信息
     */
//    @RequiresPermissions("project:room:add")
    @Log(title = "新增", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody YqgInformationRoom yqgInformationRoom)
    {
        return toAjax(yqgInformationRoomService.insertYqgInformationRoom(yqgInformationRoom));
    }

    /**
     * 修改房间基础信息
     */
//    @RequiresPermissions("project:room:edit")
    @Log(title = "修改", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody YqgInformationRoom yqgInformationRoom)
    {
        return toAjax(yqgInformationRoomService.updateYqgInformationRoom(yqgInformationRoom));
    }

    /**
     * 删除房间基础信息
     */
//    @RequiresPermissions("project:room:remove")
    @Log(title = "删除", businessType = BusinessType.DELETE)
    @DeleteMapping("/{IDs}")
    public AjaxResult remove(@PathVariable Long[] IDs)
    {
        return toAjax(yqgInformationRoomService.deleteYqgInformationRoomByIDs(IDs));
    }
}
